<div class="accordion" id="employees">
<?php
    if (isset($_POST['changeEmployeeStatus'])) {
        modifyEmployee($_SESSION['userName'], $_SESSION['userPassHash'], $_POST['userName'], $_POST['dataHash'], $_POST['empFname'], $_POST['empLname'], $_POST['startDate'], $_POST['endDate'], $_POST['empStatus'], $_POST['address'], $_POST['email'], $_POST['phoneNum'], $_POST['wage']);
    }
    $getAccountsResult = getAccounts($_SESSION['userName'], $_SESSION['userPassHash']);
    foreach ($getAccountsResult["results"] as $accountEntry) {
            viewEmpProfiles($accountEntry["accName"]);
    }

?>
</div>

<?php
function viewEmpProfiles($accName){
    $getProfileResults = showEmployeeInfo($_SESSION["userName"], $_SESSION["userPassHash"], $accName);
    $errorMessage = $getProfileResults[0];
    if($errorMessage == ErrorCode::successRead){
        $profile = $getProfileResults[1];
        ?>

        <form action="" method="post">
            <div class="accordion-group">
                <div class="accordion-heading">
                    <a class="accordian-toggle" data-toggle="collapse" data-parent="#employees" href="#<?php echo("$accName"); ?>"><?php echo($accName);?></a>
                </div>
                <div id="<?php echo($accName); ?>" class="accordion-body-collapse">
                    <div class="accordion-inner">
                        <table class="table table-condensed table-striped">
                            <tr class="row">
                                <th colspan="3">EmployeeStatus</th>
                            </tr>
                            <tr class="row">
                                <td><?php
                                $currentStatus = $profile['empStatus'];
                                if($currentStatus == "") {
                                    $currentStatus = "Not Available";
                                }
                                echo ($currentStatus);
                                ?></td>
                                <td><select name="empStatus">
                                    <option <?php if($currentStatus == "Manager") echo("selected"); ?> value="Manager">Manager</option>
                                    <option <?php if($currentStatus == "Worker") echo("selected"); ?> value="Worker">Worker</option>
                                </select>
                                <input type="hidden" name="userName" value="<?php echo($accName); ?>" />
                                <input type="hidden" name="dataHash" value="<?php echo($getProfileResults['hash']); ?>" />
                                <input type="hidden" name="empFname" value="<?php echo($profile['empFname']); ?>" />
                                <input type="hidden" name="empLname" value="<?php echo($profile['empLname']); ?>" />
                                <input type="hidden" name="startDate" value="<?php echo($profile['startDate']); ?>" />
                                <input type="hidden" name="endDate" value="<?php echo($profile['endDate']); ?>" />
                                <input type="hidden" name="address" value="<?php echo($profile['address']); ?>" />
                                <input type="hidden" name="email" value="<?php echo($profile['email']); ?>" />
                                <input type="hidden" name="phoneNum" value="<?php echo($profile['phoneNum']); ?>" />
                                <input type="hidden" name="wage" value="<?php echo($profile['wage']); ?>" />
                                </td>
                                <td><input type="submit" name="changeEmployeeStatus" value="Send" /><input type="reset" value="reset" /></td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </form>

        <?php
    }
}
?>